<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2017-03-17
 * Time: 15:38
 */

namespace app\src\sunsun\transfer\action;

use app\src\base\helper\ResultHelper;
use GatewayClient\Gateway;

require_once __DIR__ . '/../../../../../vendor/autoload.php';

//设置register服务地址
//transfer register服务 端口1250
Gateway::$registerAddress = "101.37.37.167:1250";

class TransferBaseAction
{
    public function sendReqToGroup($did, $data)
    {
        if (empty($data)) {
            return ResultHelper::error('不能发送空数据');
        }

        Gateway::sendToGroup($did, $data);
        return ResultHelper::success('send success');
    }

    public function getAllClientCount()
    {
        return ResultHelper::success(Gateway::getAllClientCount());
    }

    public function getAllGroupClientInfo()
    {
        return ResultHelper::success(Gateway::getAllClientInfo());
    }

    public function clientInfoByGroup($group)
    {
        return ResultHelper::success(Gateway::getClientInfoByGroup($group));
    }

    public function clientCountByGroup($group)
    {
        return ResultHelper::success(Gateway::getClientCountByGroup($group));
    }
}